//引入 用来发送请求 的方法， 一定要把路径补全
import { request } from "../../request/index.js";
// import regeneratorRuntime from '../../lib/runtime/runtime';
//Page Object
Page({
  data: {
    //轮播图数组
    swiperList: [],
    //导航数组
    cateList: [],
    //楼层数据
    floorList: []
  },
  //页面开始加载时触发
  onLoad: function (options) {
    //1. 发送异步请求获取轮播图数据
    // wx.request({
    //   url: 'https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata',
    //   success: (result) => {
    //     this.setData({
    //       swiperList: result.data.message
    //     })
    //   }
    // });
    // request({ url: "https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata" })
    //   .then(result => {
    //     this.setData({
    //       swiperList: result.data.message
    //     })
    //   })
    this.getSwiperList();
    this.getCateList();
    this.getFloorList()
  },

  //获取轮播图数据
  getSwiperList() {
    request({ url: "/home/swiperdata" })
      .then(result => {
        this.setData({
          swiperList: result
        })
      })
  },
  //获取分类导航数据
  getCateList() {
    request({ url: "/home/catitems" })
      .then(result => {
        this.setData({
          cateList: result
        })
      })
  },
  //获取楼层数据
  getFloorList() {
    request({ url: "/home/floordata" })
      .then(result => {
        this.setData({
          floorList: result
        })
      })
  }
});
